package tech.aistar.prj.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.prj.entity.User;

import java.util.List;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2020/9/15 4:48 下午
 */
public interface UserMapper {
    /**
     * 根据姓名查找
     * @param username
     * @return
     */
    @Select("select * from tbl_user where user_name=#{value}")
    User finByUserName(String username);

    /**
     * 查询全部
     * @return
     */
    @Select("select * from tbl_user")
    List<User> findAll();

    /**
     * 插入一个用户
     * @param user
     */
    @Insert("insert into tbl_user(user_name,password,birthday,gender) values(#{userName},#{password},#{birthday},#{gender})")
    void save(User user);

    /**
     * 根据id更新
     * @param user
     */
    @Update("update tbl_user set user_name=#{userName},password=#{password},birthday=#{birthday},gender=#{gender} where id=#{id}")
    void updateById(User user);

    /**
     * 根据id删除
     * @param user
     */
    @Delete("delete from tbl_user where id=#{id}")
    void delById(Integer id);
}

